#ifndef CTL_H
#define CTL_H

#include "common_data.h"

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <netinet/tcp.h>
#include <stdio.h>
#include <errno.h>
#include <arpa/inet.h>
#include <assert.h>

//uint16_t SERVER_PORT = 48700;
//uint32_t SERVER_IP = INADDR_ANY;
#define SERVER_IP "192.168.20.1"
//#define SERVER_IP "127.0.0.1"
#define CTL_SERVER_PORT 48700
#define CTL_TIME_KEEPALIVE 10000

int ctl_connect(int *sock);
int ctl_con_check(int sock);
int ctl_con_close(int sock);

void set_connect_syn_max(int sock);

#ifdef __cplusplus
extern "C" {
#endif

typedef enum{
    CTL_TASK
  , CTL_INTERRUPT
  , CTL_STOP
  , CTL_RESUM
} CTL_COMMAND_t;


void enable_keepalive(int sock);

int recv_cmd(int sock, CTL_COMMAND_t* cmd);

int send_cmd(int sock, CTL_COMMAND_t* cmd);

int recv_task(int sock, flight_task_t* tsk);

int send_task(int sock, flight_task_t* tsk);

#ifdef __cplusplus
};
#endif

#endif // CTL_H
